package copiaClase8;

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;


@SuppressWarnings("serial")
public class ClaFraCol extends JFrame implements ActionListener {
	
	private static final Color ROJO = new Color(255, 0, 0);
	private static final Color VERDE = new Color(0, 255, 0);
	private static final Color AZUL = new Color(0, 0, 255);	
	
	private int iConRoj, iConVer, iConAzul;
	private JButton jbRojo, jbVerde, jbAzul;
	private JPanel jpBotones;
	private ClaPanCol cpc;


	public ClaFraCol() {
		super("Colores Primarios");
		iConRoj = iConVer = iConAzul = 0;
		this.setLayout(new BorderLayout());
		this.setSize(600, 600);
		creaVentana();
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setVisible(true);
	}
	

	private void creaVentana() {
		creaBotones();
		
		jpBotones = CreaPanel(new FlowLayout());
		jpBotones.add(jbRojo);
		jpBotones.add(jbVerde);
		jpBotones.add(jbAzul);
		jbRojo.addActionListener(this);
		jbVerde.addActionListener(this);
		jbAzul.addActionListener(this);
		
		this.add("South", jpBotones);
		cpc = new ClaPanCol();
		this.add("Center", cpc);
	}


	private JPanel CreaPanel(LayoutManager fm) {
		JPanel p = new JPanel();
		p.setLayout(fm);
		p.setBackground(Color.GRAY);
		return p;
	}


	private void creaBotones() {

		jbRojo = haceBoton("Rojo", ROJO);
		jbVerde = haceBoton("Verde", VERDE);
		jbAzul = haceBoton("Azul", AZUL);
		
	}

	private JButton haceBoton(String sNom, Color cCol) {
		JButton b = new JButton(sNom);
		//b.setBackground(cCol);
		b.setForeground(cCol);
		b.setFont(new Font("Courier", Font.BOLD, 24));
		return b;
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		
		}
		
	}


